package gene.android.accountingpro.equations;

import gene.android.accountingpro.finals.EquationNames;
import gene.android.accountingpro.finals.FieldList;

import java.util.ArrayList;
import java.util.List;

public class ReturnOnEquityRatio extends Equation{
	
	private double net_income;
	private double preferred_dividends;
	private double average_common_equity;
	
	public ReturnOnEquityRatio(){}
	
	public ReturnOnEquityRatio(double netIncome, double preferredDividends, double averageCommonEquity)
	{
		this.net_income = netIncome;
		this.preferred_dividends = preferredDividends;
		this.average_common_equity = averageCommonEquity;
		value = ( ( net_income - preferred_dividends ) / average_common_equity );
	}
	
	

	@Override
	public String getEquationName() {
		return EquationNames.RETURN_ON_EQUITY_RATIO;
	}

	@Override
	public List<String> getRequiredFields() {
		List<String> requiredFields = new ArrayList<String>();
		requiredFields.add( FieldList.NET_INCOME );
		requiredFields.add( FieldList.PREFERRED_DIVIDENDS );
		requiredFields.add( FieldList.AVERAGE_COMMON_EQUITY );
		return requiredFields;
	}

	@Override
	public void setValues(double[] values) {
		net_income = values[0];
		preferred_dividends = values[1];
		average_common_equity = values[2];
		solve();
	}

	@Override
	public String getSolvedEquationString() {
		return "( ( " + net_income +" - " +preferred_dividends +" ) / ( " + average_common_equity +" ) ) = " + value;
	}

	@Override
	public String getEquationString() {
		return "( ( " + FieldList.NET_INCOME +" - " +FieldList.PREFERRED_DIVIDENDS +" ) / ( " + FieldList.AVERAGE_COMMON_EQUITY +" ) )";
	}

	@Override
	public void solve() {
		value = ( ( net_income - preferred_dividends ) / average_common_equity );
	}

}
